#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > cc2_r12_aux_ch4_sym_a3_f12.info <<'%EOF%'
   cc2_r12_aux_ch4_sym_a3_f12
   -----------
   Molecule:         Methane (CH4)
   Wave Function:    CC2-R12 / 6-311G**
   Test Purpose:     Check R12 method with correlation factor f12
                     for Ansatz 2 with auxiliary basis function
%EOF%

#######################################################################
#  MOLECULE INPUT
#######################################################################
cat > cc2_r12_aux_ch4_sym_a3_f12.mol <<'%EOF%'
BASIS
6-311G** 6-311G**
Direct CC2-R12/B calculation using symmetry

    4    2 XY XZ
 1      6.    1
C      0.000000000000000   0.000000000000000   0.000000000000000       *
 1      1.    1
H      1.276731000000000   1.276731000000000   1.276731000000000       *
 2      6.    1
C      0.000000000000000   0.000000000000000   0.000000000000000       *
 2      1.    1
H      1.276731000000000   1.276731000000000   1.276731000000000       *
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > cc2_r12_aux_ch4_sym_a3_f12.dal <<'%EOF%'
**DALTON INPUT
.RUN WAVE FUNCTION
.DIRECT
*MOLBAS
.R12AUX
**INTEGRALS
.R12GTG
 1
 1.0 0.0
**WAVE FUNCTION
.CC
*ORBITAL INPUT
.MOSTART
 H1DIAG
*SCF IN
.THRESH
 1.0D-10
*CC INPUT
.CC2
.PRINT
 5
.FROIMP
 1 0 0 0
 0 0 0 0
.THRENR
 1.0D-10
.MAX IT
 300
*CCEXCI
.THREXC
 1.D-8
.NCCEXCI
 4 4 4 4
*R12 INPUT
.NO HYB
.CC2
 3B
**END OF DALTON INPUT
%EOF%

#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >cc2_r12_aux_ch4_sym_a3_f12.check
cat >>cc2_r12_aux_ch4_sym_a3_f12.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi   

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

#             Total SCF   energy:                   -40.1917720926
#             Total MP2-R12/B energy:               -40.3940351575
#             Total CC2-R12/B energy:               -40.3953862545
# 
# 
#  +=============================================================================+
#  |  sym. | Exci.  |        CC2-R12/B  Excitation energies            | ||T1||  |
#  |(spin, |        +------------------------------------------------------------+
#  | spat) |        |     Hartree    |       eV.      |     cm-1       |    %    |
#  +=============================================================================+
#  | ^1A   |    1   |     0.4914836  |      13.37395  |    107868.191  |  97.34  |
#  | ^1A   |    2   |     0.4914836  |      13.37395  |    107868.191  |  97.33  |
#  | ^1A   |    3   |     0.5431575  |      14.78007  |    119209.301  |  97.10  |
#  | ^1A   |    4   |     0.6382924  |      17.36882  |    140088.992  |  97.38  |
#  +-----------------------------------------------------------------------------+
#  | ^1B2  |    1   |     0.4176046  |      11.36360  |     91653.620  |  97.02  |
#  | ^1B2  |    2   |     0.4827791  |      13.13709  |    105957.755  |  96.99  |
#  | ^1B2  |    3   |     0.4915543  |      13.37587  |    107883.691  |  97.15  |
#  | ^1B2  |    4   |     0.6363614  |      17.31627  |    139665.175  |  97.13  |
#  +-----------------------------------------------------------------------------+
#  | ^1B1  |    1   |     0.4176046  |      11.36360  |     91653.620  |  97.02  |
#  | ^1B1  |    2   |     0.4827791  |      13.13709  |    105957.755  |  96.99  |
#  | ^1B1  |    3   |     0.4915543  |      13.37587  |    107883.691  |  97.15  |
#  | ^1B1  |    4   |     0.6363614  |      17.31627  |    139665.175  |  97.13  |
#  +-----------------------------------------------------------------------------+
#  | ^1B3  |    1   |     0.4176046  |      11.36360  |     91653.620  |  97.02  |
#  | ^1B3  |    2   |     0.4827791  |      13.13709  |    105957.755  |  96.99  |
#  | ^1B3  |    3   |     0.4915543  |      13.37587  |    107883.691  |  97.15  |
#  | ^1B3  |    4   |     0.6363614  |      17.31627  |    139665.175  |  97.13  |
#  +=============================================================================+
# 
#
CRIT1=`$GREP "Total MP2-R12/B energy:     * \-40\.3940351575" $log | wc -l`
TEST[1]=`expr	$CRIT1`
CTRL[1]=2
ERROR[1]="MP2-R12/B ENERGY NOT CORRECT"
CRIT2=`$GREP "Total CC2-R12/B energy:     *  \-40\.3953862545" $log | wc -l`
TEST[2]=`expr	$CRIT1`
CTRL[2]=2
ERROR[2]="CC2-R12/B ENERGY NOT CORRECT"
CRIT3=`$GREP "[ \|]* \^1A[ \|]* 1[ \|]* ( |0)\.49148..[ \|]* 13\.3739.[ \|]* 107868\....[ \|]* 97\.3.[ \|]" $log | wc -l`
TEST[3]=`expr   $CRIT3`
CTRL[3]=1
ERROR[3]="CC2-R12/B 1A1 EXCITATION ENERGY NOT CORRECT"
CRIT4=`$GREP "[ \|]* \^1A[ \|]* 2[ \|]* ( |0)\.49148..[ \|]* 13\.3739.[ \|]* 107868\....[ \|]* 97\.3.[ \|]" $log | wc -l`
TEST[4]=`expr   $CRIT4`
CTRL[4]=1
ERROR[4]="CC2-R12/B 2A1 EXCITATION ENERGY NOT CORRECT"
CRIT5=`$GREP "[ \|]* \^1A[ \|]* 3[ \|]* ( |0)\.54315..[ \|]* 14\.7800.[ \|]* 119209\....[ \|]* 97\.1.[ \|]" $log | wc -l`
TEST[5]=`expr   $CRIT5`
CTRL[5]=1
ERROR[5]="CC2-R12/B 3A1 EXCITATION ENERGY NOT CORRECT"
CRIT6=`$GREP "[ \|]* \^1A[ \|]* 4[ \|]* ( |0)\.63829..[ \|]* 17\.3688.[ \|]* 140088\....[ \|]* 97\.3.[ \|]" $log | wc -l`
TEST[6]=`expr   $CRIT6`
CTRL[6]=1
ERROR[6]="CC2-R12/B 4A1 EXCITATION ENERGY NOT CORRECT"
CRIT7=`$GREP "[ \|]* \^1B2[ \|]* 1[ \|]* ( |0)\.41760..[ \|]* 11\.3636.[ \|]* 91653\....[ \|]* 97\.0.[ \|]" $log | wc -l`
TEST[7]=`expr   $CRIT7`
CTRL[7]=1
ERROR[7]="CC2-R12/B 1B2 EXCITATION ENERGY NOT CORRECT"
CRIT8=`$GREP "[ \|]* \^1B2[ \|]* 2[ \|]* ( |0)\.48277..[ \|]* 13\.1370.[ \|]* 105957\....[ \|]* 96\.9.[ \|]" $log | wc -l`
TEST[8]=`expr   $CRIT8`
CTRL[8]=1
ERROR[8]="CC2-R12/B 2B2 EXCITATION ENERGY NOT CORRECT"
CRIT9=`$GREP "[ \|]* \^1B2[ \|]* 3[ \|]* ( |0)\.49155..[ \|]* 13\.3758.[ \|]* 107883\....[ \|]* 97\.1.[ \|]" $log | wc -l`
TEST[9]=`expr   $CRIT9`
CTRL[9]=1
ERROR[9]="CC2-R12/B 3B2 EXCITATION ENERGY NOT CORRECT"
CRIT10=`$GREP "[ \|]* \^1B2[ \|]* 4[ \|]* ( |0)\.63636..[ \|]* 17\.3162.[ \|]* 139665\....[ \|]* 97\.1.[ \|]" $log | wc -l`
TEST[10]=`expr   $CRIT10`
CTRL[10]=1
ERROR[10]="CC2-R12/B 4B2 EXCITATION ENERGY NOT CORRECT"
CRIT11=`$GREP "[ \|]* \^1B1[ \|]* 1[ \|]* ( |0)\.41760..[ \|]* 11\.3636.[ \|]* 91653\....[ \|]* 97\.0.[ \|]" $log | wc -l`
TEST[11]=`expr   $CRIT11`
CTRL[11]=1
ERROR[11]="CC2-R12/B 1B1 EXCITATION ENERGY NOT CORRECT"
CRIT12=`$GREP "[ \|]* \^1B1[ \|]* 2[ \|]* ( |0)\.48277..[ \|]* 13\.1370.[ \|]* 105957\....[ \|]* 96\.9.[ \|]" $log | wc -l`
TEST[12]=`expr   $CRIT12`
CTRL[12]=1
ERROR[12]="CC2-R12/B 2B1 EXCITATION ENERGY NOT CORRECT"
CRIT13=`$GREP "[ \|]* \^1B1[ \|]* 3[ \|]* ( |0)\.49155..[ \|]* 13\.3758.[ \|]* 107883\....[ \|]* 97\.1.[ \|]" $log | wc -l`
TEST[13]=`expr   $CRIT13`
CTRL[13]=1
ERROR[13]="CC2-R12/B 3B1 EXCITATION ENERGY NOT CORRECT"
CRIT14=`$GREP "[ \|]* \^1B1[ \|]* 4[ \|]* ( |0)\.63636..[ \|]* 17\.3162.[ \|]* 139665\....[ \|]* 97\.1.[ \|]" $log | wc -l`
TEST[14]=`expr   $CRIT14`
CTRL[14]=1
ERROR[14]="CC2-R12/B 4B1 EXCITATION ENERGY NOT CORRECT"
CRIT15=`$GREP "[ \|]* \^1B3[ \|]* 1[ \|]* ( |0)\.41760..[ \|]* 11\.3636.[ \|]* 91653\....[ \|]* 97\.0.[ \|]" $log | wc -l`
TEST[15]=`expr   $CRIT15`
CTRL[15]=1
ERROR[15]="CC2-R12/B 1B3 EXCITATION ENERGY NOT CORRECT"
CRIT16=`$GREP "[ \|]* \^1B3[ \|]* 2[ \|]* ( |0)\.48277..[ \|]* 13\.1370.[ \|]* 105957\....[ \|]* 96\.9.[ \|]" $log | wc -l`
TEST[15]=`expr   $CRIT15`
CTRL[15]=1
ERROR[15]="CC2-R12/B 2B3 EXCITATION ENERGY NOT CORRECT"
CRIT16=`$GREP "[ \|]* \^1B3[ \|]* 3[ \|]* ( |0)\.49155..[ \|]* 13\.3758.[ \|]* 107883\....[ \|]* 97\.1.[ \|]" $log | wc -l`
TEST[16]=`expr   $CRIT16`
CTRL[16]=1
ERROR[16]="CC2-R12/B 3B3 EXCITATION ENERGY NOT CORRECT"
CRIT17=`$GREP "[ \|]* \^1B3[ \|]* 4[ \|]* ( |0)\.63636..[ \|]* 17\.3162.[ \|]* 139665\....[ \|]* 97\.1.[ \|]" $log | wc -l`
TEST[17]=`expr   $CRIT17`
CTRL[17]=1
ERROR[17]="CC2-R12/B 4B3 EXCITATION ENERGY NOT CORRECT"


PASSED=1
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
do 
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done 

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM 
  exit 1
fi

%EOF%
#######################################################################
